Fail when both network_id & vpc_id are set in ipaddress#99
Conversation
kiranchavala
left a comment
There was a problem hiding this comment.
The network_id is still not saved in the tfstate
"provider": "provider[\"localdomain/provider/cloudstack\"]",
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "31cd2075-41a4-4c88-a625-8b1af213026a",
"ip_address": "10.0.57.165",
"is_portable": false,
"is_source_nat": false,
"network_id": "",
"project": "ed04078f-dd1e-471d-8c3d-5fb8554a0c8a",
"tags": {},
"vpc_id": "d12f2b16-03d2-404c-9627-808ad0d73317",
"zone": "49e9ad34-8a3d-4f87-8ff5-90d65859f839"
},
"sensitive_attributes": [],
"private": "bnVsbA=="
}
# cloudstack_ipaddress.galaxy_public_ip must be replaced
-/+ resource "cloudstack_ipaddress" "galaxy_public_ip" {
~ id = "31cd2075-41a4-4c88-a625-8b1af213026a" -> (known after apply)
~ ip_address = "10.0.57.165" -> (known after apply)
~ is_source_nat = false -> (known after apply)
+ network_id = "d7617062-4305-4740-8581-a704cc9ec9e0" # forces replacement
~ tags = {} -> (known after apply)
# (4 unchanged attributes hidden)
kiranchavala
left a comment
There was a problem hiding this comment.
When I provide both network_id and vpc_id and do terraform apply
cloudstack_ipaddress.galaxy_public_ip: Creating...
╷
│ Error: set only network_id or vpc_id
When i provide only network id
cloudstack_ipaddress.galaxy_public_ip: Creating...
╷
│ Error: Error associating a new IP address: Undefined error: {"errorcode":431,"errortext":"Can't assign ip to the network directly when network belongs to VPC.Specify vpcId to associate ip address to VPC"}
│
│ with cloudstack_ipaddress.galaxy_public_ip,
│ on main.tf line 8, in resource "cloudstack_ipaddress" "galaxy_public_ip":
│ 8: resource "cloudstack_ipaddress" "galaxy_public_ip" {
When i provide only vpc_id no issues
cloudstack_ipaddress.galaxy_public_ip: Creating...
cloudstack_ipaddress.galaxy_public_ip: Creation complete after 1s [id=06ba3a09-f315-45cc-86b9-ec2a000965d2]
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "06ba3a09-f315-45cc-86b9-ec2a000965d2",
"ip_address": "10.0.57.174",
"is_portable": false,
"is_source_nat": false,
"network_id": null,
"project": "ed04078f-dd1e-471d-8c3d-5fb8554a0c8a",
"tags": {},
"vpc_id": "ab9fc295-0bcc-4a2f-85a9-b98625e02b1d",
"zone": "49e9ad34-8a3d-4f87-8ff5-90d65859f839"
},
"sensitive_attributes": []
}
]
When i provide the network id of a isolated network it's working fine and tf state contains the network id.
cloudstack_ipaddress.galaxy_public_ip: Creating...
cloudstack_ipaddress.galaxy_public_ip: Creation complete after 1s [id=11788a4d-7fb5-48cd-a009-c89b0b309a07]
"instances": [
{
"schema_version": 0,
"attributes": {
"id": "11788a4d-7fb5-48cd-a009-c89b0b309a07",
"ip_address": "10.0.57.168",
"is_portable": false,
"is_source_nat": true,
"network_id": "93f804b6-1e2b-4969-bbf8-244c93df11e2",
"project": "ed04078f-dd1e-471d-8c3d-5fb8554a0c8a",
"tags": {},
"vpc_id": null,
"zone": "49e9ad34-8a3d-4f87-8ff5-90d65859f839"
},
"sensitive_attributes": [],
"private": "bnVsbA=="
}
Do a terraform apply again , this time there is no change detacted
cloudstack_ipaddress.galaxy_public_ip: Refreshing state... [id=11788a4d-7fb5-48cd-a009-c89b0b309a07]
No changes. Your infrastructure matches the configuration.
Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.
Apply complete! Resources: 0 added, 0 changed, 0 destroyed.
81eb51d to
1b6cce4
Compare
|
Why was this necessary, though @vishesh92? Is it implied that when using a network, it'll use the ID of the VPC that the network belongs to? What about the following scenario: Maybe a comment outlining this could be useful. I'm glad to add it if y'all agree that my statement is correct. |
@klaussilveira Yes. Public IPs get assigned to the VPC itself, which is the parent of its network tiers. |
Fixes #32